import Request from "@/common/utils/request";
import { UpdateSnCheckResultDTO } from "@/types/model/inventory/dtos/inventory.dto";
import {
  InventoryDetailVO,
  SNItem,
  SnTransactionRecordVO,
} from "@/types/model/inventory/vos/inventory.vo";
import { PageList } from "@/types/model/pageList.model";

enum Api {
  GetInventoryList = "/jeecgboot/posInventoryItem/getInventoryItem",
  GetInventoryDetail = "/jeecgboot/posInventoryItem/getInventoryDetail",
  GetSnsByInventoryId = "/jeecgboot/posInventoryItem/getSnByInventoryId",
  GetSnCheckResult = "/jeecgboot/posInventoryItem/getSnCheckResult",
  UpdateSnCheckResult = "/jeecgboot/posInventoryItem/updateSnCheckResult",
  GetSnTransactionRecord = "/jeecgboot/posInventoryItem/getSnTransactionRecord",
}

export const getInventoryList = (params: any) =>
  Request.getInstance().send({
    url: Api.GetInventoryList,
    method: "GET",
    params,
  });

export const getInventoryDetail = (inventoryId: string) =>
  Request.getInstance().send<InventoryDetailVO>({
    url: Api.GetInventoryDetail,
    method: "GET",
    params: {
      inventoryId,
    },
  });

export const getSnsByInventoryId = (params: string) =>
  Request.getInstance().send<PageList<SNItem>>({
    url: Api.GetSnsByInventoryId,
    method: "GET",
    params: params,
  });

export const getSnCheckResult = (snId: string) => {
  return Request.getInstance().send({
    url: Api.GetSnCheckResult,
    method: "GET",
    params: {
      snId,
    },
  });
};

export const updateSnCheckResult = (params: UpdateSnCheckResultDTO) =>
  Request.getInstance().send({
    url: Api.UpdateSnCheckResult,
    method: "POST",
    data: params,
  });

export const getSnTransactionRecord = (snId: string) =>
  Request.getInstance().send<SnTransactionRecordVO[]>({
    url: Api.GetSnTransactionRecord,
    method: "GET",
    params: { snId },
  });
